package network;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class Client {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		while(true){
			try {

				Socket s = new Socket("130.132.135.111", 8080);

				BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
				bw.write((new BufferedReader(new InputStreamReader(System.in))).readLine());
				bw.newLine();
				bw.write("END\n");
				bw.flush();

				BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
				String total = "";
				String in = br.readLine();
				while(in != null && !in.equals("END")){
					total += in;
					in = br.readLine();
				}
				System.out.println("Response: " + total);
				s.close();
			} catch (IOException e) {
				System.out.println("error: " + e.getMessage());
				e.printStackTrace();
			}
		}
	}

}
